Skip to content

fix: compare Windows scheduled-import paths case-insensitively - #582

Merged
nashsu merged 1 commit into
nashsu:mainfrom
chuenchen309:fix/scheduled-import-windows-case
Jul 27, 2026
Merged

fix: compare Windows scheduled-import paths case-insensitively#582
nashsu merged 1 commit into
nashsu:mainfrom
chuenchen309:fix/scheduled-import-windows-case

Conversation

@chuenchen309

Copy link
Copy Markdown
Contributor

Why

The scheduled-import self-import guard compares normalized paths case-sensitively. On Windows, the same project can therefore appear unrelated when a drive-letter or UNC path uses different casing, allowing a project-managed directory to be selected as an external scheduled-import root.

What

Reuse the existing scheduled-import database path key for both sides of containment checks. That key case-folds drive-letter and UNC paths while leaving POSIX paths case-sensitive.

Tests

  • Added regression coverage for drive-letter paths, UNC paths, and POSIX case sensitivity
  • Parent commit repro: 1 failed / 12 passed (false, expected true)
  • npm run test:mocks -- src/lib/scheduled-import.test.ts (13 passed)
  • npm run test:mocks (115 files, 1676 tests passed)
  • npm run typecheck
  • npm run build

Disclosure: this focused change was produced with AI assistance and validated with the regression test, full mock suite, typecheck, and production build.

Reuse the scheduled-import database path key for containment checks so drive-letter and UNC paths follow Windows case-insensitive filesystem semantics.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@nashsu
nashsu merged commit dbe465f into nashsu:main Jul 27, 2026
3 checks passed
nashsu pushed a commit that referenced this pull request Jul 27, 2026
…ws roots

scheduledImportDestinationForFile()'s containment check compares
`source === importRoot` / `source.startsWith(importRoot + "/")`
case-sensitively, but Windows drive-letter and UNC paths are
case-insensitive. When the source file's casing differs from the
configured import root (e.g. root "C:/Users/Me/Inbox", source
"c:/users/me/inbox/sub/report.pdf"), the containment check fails and
the file falls back to file.name only, silently flattening its nested
directory structure (and risking same-name collisions from different
folders).

Fix: reuse the existing drive-letter/UNC case-folding used by
dbDirectoryKey (extracted into a shared caseFoldPath helper) for the
comparison only; the returned path still uses the source's original
casing.

Verified: new test red before fix (flattened to file.name), green
after; full scheduled-import.test.ts (13) and test:mocks (1679) pass;
typecheck clean.

Note: distinct from #582 (also open, same file) — that fixes
isPathInside()'s self-import-guard case sensitivity; this fixes
scheduledImportDestinationForFile()'s relative-path calculation. No
functional overlap between the two.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants